package com.niiwoo.civet.trade.configuration;

import com.niiwoo.civet.trade.constant.RabbitConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by daizhiyue on 2018/4/23.
 */
@Configuration
public class InvestStopByEvaluationMqConfiguration {
	//**********************
	//投资金额已达该风险类型投资上限处理mq配置
	//**********************
	@Bean
	public Exchange investEventExchange() {
		return new DirectExchange(RabbitConstant.Exchange.INVEST_EVENT, true, true);
	}

	@Bean
	public Queue investEventQueue() {
		return new Queue(RabbitConstant.Queue.INVEST_EVENT, true);
	}

	@Bean
	public Binding investEventBinding() {
		return BindingBuilder.bind(investEventQueue()).to(investEventExchange()).with(RabbitConstant.RoutingKey.INVEST_EVENT).noargs();
	}

	@Bean
	public Exchange investStopByEvaluationExchange() {
		return new DirectExchange(RabbitConstant.Exchange.INVEST_STOP_BY_EVALUATION_DEAL, true, true);
	}

	@Bean
	public Queue investStopByEvaluationQueue() {
		return new Queue(RabbitConstant.Queue.INVEST_STOP_BY_EVALUATION_DEAL, true);
	}

	@Bean
	public Binding investStopByEvaluationBinding() {
		return BindingBuilder.bind(investStopByEvaluationQueue()).to(investStopByEvaluationExchange()).with(RabbitConstant.RoutingKey.INVEST_STOP_BY_EVALUATION_DEAL).noargs();
	}
}
